package ai.people.core.security.entity;

import ai.people.netmon.framework.domain.system.vo.NmSystemUserVO;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

/**
 * 用户身份验证信息
 *
 * @author yuanqinglong
 * @date 2022/04/16
 */
@Getter
@Setter
@EqualsAndHashCode(callSuper = true)
public class AuthenticationUser extends User implements Serializable {

    private static final long serialVersionUID = -277847907006165797L;

    public AuthenticationUser(String username, String password, Collection<? extends GrantedAuthority> authorities) {
        super(username, password, authorities);
    }

    public AuthenticationUser(Long userId, List<Long> userRoleId, List<String> userRoleCodes, String username, String userPhone, String password, Integer joinMaxCount, String label, String place, Collection<? extends GrantedAuthority> authorities) {
        super(username, password, authorities);
        this.joinMaxCount = joinMaxCount;
        this.label = label;
        this.place = place;
        this.userId = userId;
        this.userRoleId = userRoleId;
        this.userRoleCode = userRoleCodes;
        this.userPhone = userPhone;
    }

    public AuthenticationUser(NmSystemUserVO nmSystemUserVO, List<Long> roleIds, Collection<? extends GrantedAuthority> authorities){
        super(nmSystemUserVO.getAccount(), nmSystemUserVO.getPassword(), authorities);
        this.joinMaxCount = nmSystemUserVO.getJoinMaxCount();
        this.label = nmSystemUserVO.getLabel();
        this.place = nmSystemUserVO.getPlace();
        this.userId = nmSystemUserVO.getId();
        this.userRoleId = roleIds;
        this.userPhone = nmSystemUserVO.getPhone();
    }
    /**
     * 用户id
     */
    private Long userId;

    /**
     * 用户电话
     */
    private String userPhone;
    /**
     * 用户角色id
     */
    private List<Long> userRoleId;
    /**
     * 用户角色代码
     */
    private List<String> userRoleCode;
    /**
     * 加入最大计数
     */
    private Integer joinMaxCount;
    /**
     * 标签
     */
    private String label;
    /**
     * 地方
     */
    private String place;
    /**
     * 用户登录时间
     */
    private Long userLoginTime;

    /**
     * ip白名单
     */
    private String ipWhiteList;
    /**
     * 访问来源
     */
    private String accessibleSource;
    /**
     * 经验值
     */
    private Long exp;



}
